package practice;

import java.util.Scanner;

public class Max {
    public static int compareTwoValue(int a,int b){
            return (a>b)?a:b;//比较两个数大小
    }
    public static int  compareThreeValue(int a,int b,int c){
        int max;
        return max=((max=(a>b)?a:b)>c?max:c);
    }
    public static void compareArrayMax(){
        Scanner stdIn=new Scanner(System.in);
        System.out.println("你想放入几个元素？");
        int n=stdIn.nextInt();
        int[] arr=new int[n];
        System.out.println("请输入各个元素的值：");
        for (int i = 0; i <arr.length; i++) {
            arr[i]=stdIn.nextInt();
        }
        int max=arr[0];//假设最大值是第一个数
        int min=arr[0];

        for (int i = 0; i <arr.length ; i++) {
            if (max<arr[i])
                max=arr[i];
            if (min>arr[i])
                min=arr[i];
        }
        System.out.print("这个数组为：");
        for (int i = 0; i <arr.length ; i++) {

            System.out.print(arr[i]+" ");
        }
        System.out.println();
        System.out.println("这个数组的最大值为："+max+"\t最小值为："+min);

    }


}
